package com.wy2cloud.sample.zuulandauthserver.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.wy2cloud.sample.zuulandauthserver.entity.AuthorizeAuthority;



/** 
 * AuthorizeAuthority 仓储层
 * @author wuyy(16349023@qq.com)
 * @date 2018年04月04日 14:42:42
 *
 */
public interface AuthorizeAuthorityRepository extends JpaRepository<AuthorizeAuthority, String> {
    @Query(nativeQuery=true,value="SELECT authority.* FROM authorize_authority authority WHERE authority.id IN ( SELECT roleAuthority.authority_id FROM authorize_role_authority roleAuthority JOIN authorize_user_role userRole ON userRole.role_id = roleAuthority.role_id WHERE userRole.user_id = ?1 )")
    List<AuthorizeAuthority> listUserAuthorities(String userId);
}